package top.huanyv.tools.utils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class EncodeUtil {

    /**
     * BASE64编码
     */
    public static String encodeBASE64(String key) {
        return encodeBASE64(key.getBytes(StandardCharsets.UTF_8));
    }

    public static String encodeBASE64(byte[] key) {
        return Base64.getEncoder().encodeToString(key);
    }

    /**
     * BASE64解码
     */
    public static byte[] decodeBASE64(String key) {
        return Base64.getDecoder().decode(key);
    }

}